package com.regal.packet;

import java.util.Map;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;

public class RegUser extends IQ {

	/**
	 * Element name of the packet extension.
	 */
	public static final String ELEMENT_NAME = "query";

	/**
	 * Namespace of the packet extension.
	 */
	public static final String NAMESPACE = "jabber:iq:register";

	private Map<String, String> attributes = null;

	public String getChildElementXML() {
		StringBuffer buf = new StringBuffer();
		buf.append("<query xmlns=\"" + NAMESPACE + "\">");

		if (attributes != null && attributes.size() > 0) {
			for (String name : attributes.keySet()) {
				String value = attributes.get(name);
				if(value != null){
					buf.append("<").append(name).append(">");
				
					buf.append(value);
				
					buf.append("</").append(name).append(">");
				}
			}
		}
		buf.append("</query>");
		return buf.toString();

	}
	
	public Map<String, String> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, String> attributes) {
		this.attributes = attributes;
	}

	/**
	 * An IQProvider for CompanyListIQ packet.
	 * 
	 * @author Derek DeMoro
	 */
	public static class Provider implements IQProvider {

		public Provider() {
			super();
		}

		public IQ parseIQ(XmlPullParser parser) throws Exception {

			RegUser recRoster = new RegUser();
			return recRoster;
		}
	}

}
